package com.campus.food.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * 文件上传配置类
 * 读取application.yml中的文件上传配置
 *
 * @author Claude3.7 Sonnet
 * @since 2025-05-29
 */
@Component
@ConfigurationProperties(prefix = "file.upload")
public class FileUploadConfig {
    
    /**
     * 文件上传基础路径
     */
    private String basePath;
    
    /**
     * 商家图片上传路径
     */
    private String merchantPath;
    
    /**
     * 食品图片上传路径
     */
    private String foodPath;
    
    /**
     * 用户头像上传路径
     */
    private String avatarPath;
    
    /**
     * 评论图片上传路径
     */
    private String reviewPath;
    
    /**
     * 允许上传的文件类型
     */
    private String allowedTypes;
    
    /**
     * 是否使用原始文件名
     */
    private boolean useOriginalFilename;
    
    /**
     * 获取允许的文件类型列表
     */
    public List<String> getAllowedTypesList() {
        return Arrays.asList(allowedTypes.split(","));
    }
    
    /**
     * 获取商家图片完整上传路径
     */
    public String getMerchantUploadPath() {
        return basePath + merchantPath;
    }
    
    /**
     * 获取食品图片完整上传路径
     */
    public String getFoodUploadPath() {
        return basePath + foodPath;
    }
    
    /**
     * 获取用户头像完整上传路径
     */
    public String getAvatarUploadPath() {
        return basePath + avatarPath;
    }
    
    /**
     * 获取评论图片完整上传路径
     */
    public String getReviewUploadPath() {
        return basePath + reviewPath;
    }

    // Getters and Setters
    public String getBasePath() {
        return basePath;
    }

    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }

    public String getMerchantPath() {
        return merchantPath;
    }

    public void setMerchantPath(String merchantPath) {
        this.merchantPath = merchantPath;
    }

    public String getFoodPath() {
        return foodPath;
    }

    public void setFoodPath(String foodPath) {
        this.foodPath = foodPath;
    }

    public String getAvatarPath() {
        return avatarPath;
    }

    public void setAvatarPath(String avatarPath) {
        this.avatarPath = avatarPath;
    }

    public String getReviewPath() {
        return reviewPath;
    }

    public void setReviewPath(String reviewPath) {
        this.reviewPath = reviewPath;
    }

    public String getAllowedTypes() {
        return allowedTypes;
    }

    public void setAllowedTypes(String allowedTypes) {
        this.allowedTypes = allowedTypes;
    }

    public boolean isUseOriginalFilename() {
        return useOriginalFilename;
    }

    public void setUseOriginalFilename(boolean useOriginalFilename) {
        this.useOriginalFilename = useOriginalFilename;
    }
} 